/*
 * @Author: 张笑天
 * @Date: 2018-03-07 17:09:36
 * @Last Modified by: lyuan2018
 * @Last Modified time: 2020-08-19 15:24:55
 */
import React from 'react';

class Layout extends React.Component {
  static displayName = 'NewLayout';
  constructor(props) {
    super(props);
    this.prefixCls = 'wea-email-new-layout';
    this.state = {
      hideRight: props.hideRight || true,
    };
  }
  componentDidMount() {
    const { hideRight = true } = this.props;
    /* eslint-disable */
    this.setState({ hideRight });
    /* eslint-enable */
  }
  componentWillReceiveProps(nextPorps) {
    if (this.props.hideRight !== nextPorps.hideRight) {
      this.setState({ hideRight: nextPorps.hideRight });
    }
  }
  render() {
    const { hideRight } = this.state;
    const { className = '', children, rightCom } = this.props;
    return (
      <div
        className={`${this.prefixCls} ${className}`}
        style={{ paddingRight: hideRight ? 0 : 271 }}
      >
        <div className={`${this.prefixCls}-left`}>{children}</div>
        <div className={`${this.prefixCls}-right`}>{rightCom}</div>
      </div>
    );
  }
}

export default Layout;
